home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2816 < prev    next >
Encoding:
Text File  |  1996-08-06  |  3.0 KB  |  71 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.sprintlink.net!mv!usenet
  3. From: ENGR@GSSI.MV.COM (Michael Furman)
  4. Subject: Re: Object with Interrupt Service Routine
  5. Message-ID: <DL8B3G.MuB@mv.mv.com>
  6. Mime-Version: 1.0
  7. Organization: GSSI
  8. Date: Mon, 15 Jan 1996 15:30:51 GMT
  9. References: <4d6imm$okq@newsbf02.news.aol.com>
  10. X-Newsreader: WinVN 0.93.10
  11. X-Nntp-Posting-Host: gssi.mv.com
  12.  
  13. In article <4d6imm$okq@newsbf02.news.aol.com>, awhang8367@aol.com says...
  14. >
  15. >  I have been struggling to create an object that handles hardware
  16. >interrupt directly.  Particularly with the setvect function as it takes in
  17. >pointers to interrupts 
  18. >^^^^^^^^^
  19. >and not to objects.  Two things I can do (and I have accomplished ther
  20. >former):
  21. >
  22. >   1)  Use an interrupt service routine to call the object.
  23.  
  24. If you mean "call nonstatic member function of the object" - why not. I see
  25. only two problems:
  26.   1. - how to obtain pointer to the instance that corresponds to this 
  27. interrupt.
  28.   2. - size of current stack. If it is asynchronous interrupt - it may 
  29. happend at any time and nobody can garantee you that you have a stack space
  30. big enough for executing your function.
  31.  
  32. >   2)  directly write the address of the member function to the Interrupt
  33. >vector table
  34. You can, but only for static member function (and it probably should be 
  35. declared with "interrupt" keyword - but it, like other staff, highly CPU/OS
  36. dependable). To call nonstatic member function you must supply pointer to the 
  37. instance of your class (my problem "1").
  38. >
  39. >  Both implementations seems to be very clumsy.  Does anyone know of a
  40. >good way of doing it?  Any pointer or email interrupt will be greatly
  41. >appreciated.
  42.  
  43. You have not defined exactly what do you need. I can suppose 2 variants:
  44.  
  45. 1. Just one interrupt handling. In this case you can use static 
  46. interrupt member function and static pointer to instance of your class. This 
  47. function can call some nonstatic member function using this pointer if you
  48. need that. And you will probably need assembler code to switch to new stack
  49. frame and to restore old stack frame.
  50.  
  51. 2. You need to handle more than one interrupt. This case is more complicated:
  52. you need to hide somewere pointers to class instances for each interrupt. 
  53. There is no place in interrupt table - and the only way I can see (and use) - 
  54. reserve space in class and put there for each instance a small assemler stub,
  55. which load pointer to this instance to some register and transfer control to
  56. common ISR static function.
  57.  
  58. This works for PC/MSDOS - the only thing wee need (I believe) - is the common
  59. address space for data and instructions, or at least ability to allocate
  60. and modify program memory (in that case stubs must be allocated there).
  61.  
  62.  
  63. -- 
  64. ---------------------------------------------------------------
  65. Michael Furman,                       (603)893-1109
  66. Geophysical Survey Systems, Inc.  fax:(603)889-3984
  67. 13 Klein Drive - P.O. Box 97          engr@gssi.mv.com 
  68. North Salem, NH 03073-0097            71543.1334@compuserve.com
  69. ---------------------------------------------------------------
  70.  
  71.